const { resolve } = require('path')

const Router = require('koa-router')
const router = new Router()

const { MANAGE_BASEROUTER } = require(resolve(__dirname, '../config/default'))

const { verifyToken } = require(resolve(__dirname, '../middleware/index'))

const {
  categoryAdd,
  categoryDel,
  categoryUp,
  categorySelect,
  categorySelectTotal,
  categorySelectOne
} = require(resolve(__dirname, '../routerHandle/managementHandle/classify'))


// 查询分类 /api/manage
router.get(MANAGE_BASEROUTER + '/classify/find', categorySelect)

// 查询单个分类 /api/manage
router.get(MANAGE_BASEROUTER + '/classify/find/one', categorySelectOne)

// 查询分类数量 /api/manage
router.get(MANAGE_BASEROUTER + '/classify/find/total', categorySelectTotal)

// 添加分类 /api/manage
router.post(MANAGE_BASEROUTER + '/classify/add', verifyToken, categoryAdd)

// 删除分类
router.post(MANAGE_BASEROUTER + '/classify/del', verifyToken, categoryDel)

// 修改分类
router.post(MANAGE_BASEROUTER + '/classify/update', verifyToken, categoryUp)



module.exports = router